-- card: 9721 from stack: in.0 -- bmap block id: 0 -- flags: 4000 -- background id: 3837 -- name: NewMenu ----- HyperTalk script ----- on opencard -- create the menus -- keep the "handles" to the menus in these globals global menu1, menu2 show menubar put NewMenu("Beep","Once","Twice","(-","Boing/9") into menu1 if menu1 is 0 then answer("Unable to make menu 'BEEP'") with "Drat" put NewMenu("Visual","Effect 1") into menu2 if menu2 is 0 then answer("Unable to make menu 'Visual'") with "Drat" end opencard on closecard -- delete the menus we've created using --the globals saved in openStack global menu1, menu2 put DeleteMenu(menu1) into menu1 -- clearing global for safety put DeleteMenu(menu2) into menu2 hide menubar end closecard on idle -- call ShowMenu every so often just in case our menus vanished global menu1, menu2, lastTick if (the ticks-lastTick)>120 then -- gives better -- performance than on every iteration put the ticks into lastTick ShowMenu(menu1) ShowMenu(menu2) end if pass idle end idle on doMenu which -- get our menu items from doMenu -- before HyperCard does... global menu1, menu2 -- for CheckMenu and -- EnableMenu below if which is "Once" then beep 1 CheckMenu menu1,1,true else if which is "Twice" then beep 1 wait 4 beep 1 CheckMenu menu1,2,true else if which is "Boing" then play "Boing" CheckMenu menu1,4,true else if which is "Effect 1" then push card visual effect dissolve to black pop card EnableMenu menu2,1,false else pass doMenu -- Remember to pass on menu commands you don't trap! end doMenu -- part 1 (button) -- low flags: 00 -- high flags: A003 -- rect: left=82 top=302 right=324 bottom=182 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Install ----- HyperTalk script ----- on mouseUp if the optionkey is down then pass mouseup end if put (long name of this stack) into sourceStack delete first word of sourceStack delete first character of sourceStack delete last character of sourceStack put "Select a stack to copy this resource into." put filename("STAK") into fname if fname is empty then hide message window exit mouseup end if if sourcestack=fname then beep Answer "Get real. You can't install it in this stack" hide message window exit mouseup end if -- ModResCopy sourceStack,fname,"XFCN","NewMenu" -- get the result if first char of it is "E" then put it into the message box beep answer "Attempt to install resource has failed." else beep answer "Resource installation successful" end if hide message window end mouseUp -- part contents for background part 5 ----- text ----- NewMenu -- part contents for background part 10 ----- text ----- 3 -- part contents for background part 6 ----- text ----- NewMenu allows you to add your own menus to a HyperCard stack. You may have up to eight menus with up to 15 items per menu. When you change userLevels, or select paint tools, or do anything to cause HyperCard to change the menu bar--your new menu will be erased from the menu bar. It is NOT gone from memory, just from the menu bar. To have it replaced automatically do the "on idle" routine shown below. This will make sure your menu is showing whenever you are in browse mode (on idle is not called when you're in button, field, or paint tools mode). All this would generally be done in a stack's script as follows: on openStack -- create the menus -- keep the "handles" to the menus in these globals global menu1, menu2 put NewMenu("Beep","Once","Twice","(-","Boing/9") into menu1 if menu1 is 0 then answer("Unable to make menu 'BEEP'") with "Drat" put NewMenu("Visual","Effect 1") into menu2 if menu2 is 0 then answer("Unable to make menu 'Visual'") with "Drat" end openStack on closeStack -- delete the menus we've created using --the globals saved in openStack global menu1, menu2 put DeleteMenu(menu1) into menu1 -- clearing global -- for safety put DeleteMenu(menu2) into menu2 end closeStack on idle -- call ShowMenu every so often just in case -- our menus vanished global menu1, menu2, lastTick if (the ticks-lastTick)>120 then -- gives better -- performance than on every iteration put the ticks into lastTick ShowMenu(menu1) ShowMenu(menu2) end if pass idle end idle on doMenu which -- get our menu items from doMenu -- before HyperCard does... global menu1, menu2 -- for CheckMenu and -- EnableMenu below if which is "Once" then beep 1 CheckMenu menu1,1,true else if which is "Twice" then beep 1 wait 4 beep 1 CheckMenu menu1,2,true else if which is "Boing" then play "Boing" CheckMenu menu1,4,true else if which is "Effect 1" then push card visual effect dissolve to black pop card EnableMenu menu2,1,false else pass doMenu -- Remember to pass on menu -- commands you don't trap! end doMenu Notice that if you want the menu to appear for all cards in the stack, you would place the NewMenu function in the stack's script and install it "on openStack" and remove it "on closeStack". If you wanted a menu to appear only for a certain background, the commands would be in that background's script and done "on openBackground" and "on closeBackground". And the commands to make a menu to appear only on a certain card would be done in that card's script "on openCard"/"on closeCard". ••• All the credit, (even the descriptions above) go to the creator of this ingenious XFCN: Nine to Five Software Company P.O. Box 915 Greenwood, IN 46142 (317) 887-2154 & Michael Long See also CheckMenu*, EnableMenu*, DeleteMenu*, and ChangeMenu*. -- part contents for background part 7 ----- text ----- Syntax: put NewMenu("Title","Item1","Item2",...,"Item n") into yourName "Title" is the name that will be put into the menubar. "Item1" through "Item n" are the names of the items in the pull down part of the menu. Add an item like "(-" to insert a divider line between menu options. You may also end items with a slash letter (as is "An item/I") to add command keys. The number the NewMenu function returns is a reference number to the menu you just installed. You MUST have this number to delete or make changes to the menu later on!